/**
 * @FileName: ProductSkuService.java
 * @Author
 * @Description:
 * @Date 2016年5月3日 下午3:43:19
 * @CopyRight ZTE Corporation
 */
package cn.hpclub.server.service.product;

import java.util.List;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

public class ProductSkuService{
    public static final ProductSkuService service = new ProductSkuService();

    /**
     * 
     * @Title: updateProductSku
     * @Description:编辑后更新商品sku：1、删除原有sku；2、保存新的sku
     * @param productSku
     * @return boolean
     */
    // public boolean updateProductSku(ProductSku productSku){
    // if(deleteProductSku(productSku.get(ProductSku.PRODUCT_ID))){
    // return productSku.save();
    // }
    //
    // return false;
    // }

    /**
     * 
     * @Title: deleteProductSku
     * @Description:根据productId删除商品sku
     * @param productId
     * @return boolean
     */
    public boolean deleteProductSku(String productId){
        String sql = "select * from product_sku where enabled=1 and product_id=?";
        List<Record> productSkus = Db.find(sql, productId);
        if(productSkus == null){
            return false;
        }
        for(Record r : productSkus){
            Db.delete("product_sku", r);
        }

        return true;
    }

}
